<template>
	<view class="content">
		<!-- #ifdef H5 || APP-PLUS -->
		<view class="message-title">
			<commonTitle title="帮助与咨询"></commonTitle>
		</view>
		<!-- #endif -->
		<view class="list-scroll-content nopadding">
			<!-- 六大板块 -->
			<view class="help-block">
				<view class="block-item" @tap="goQuestionDetail(25)">
					<image src="../../static/common/img01.png" class="item-img01"></image>
					<view class="item-text">软件使用问题</view>
				</view>
				<view class="block-item" @tap="goQuestionDetail(26)">
					<image src="../../static/common/img02.png" class="item-img02"></image>
					<view class="item-text">关于钱包问题</view>
				</view>
				<view class="block-item" @tap="goQuestionDetail(27)">
					<image src="../../static/common/img03.png" class="item-img03"></image>
					<view class="item-text">好友相关问题</view>
				</view>
				<view class="block-item" @tap="goQuestionDetail(28)">
					<image src="../../static/common/img04.png" class="item-img04"></image>
					<view class="item-text">订单明细问题</view>
				</view>
				<view class="block-item" @tap="goQuestionDetail(29)">
					<image src="../../static/common/img05.png" class="item-img05"></image>
					<view class="item-text">信用相关问题</view>
				</view>
				<view class="block-item" @tap="goQuestionDetail(30)">
					<image src="../../static/common/img01.png" class="item-img05"></image>
					<view class="item-text">分享商品问题</view>
				</view>
			</view>
			<!-- 背景图 -->
			<image src="../../static/common/newDriver-bg.png" class="newDriver-bg"></image>
			<!-- 常见问题 -->
			<view class="question">常见问题</view>
			<!-- <view class="question-block">
				<view class="question-detail" v-if="commonQuestionList.length>0"
				v-for="(item,index) in commonQuestionList" :key="index"
				@tap="getQuestionDetail(item.helpId)"
				>
					<view class="question-text">{{item.helpName}}</view>
					<image class="qusetion-icon" src="../../static/common/question-icon.png"></image>
				</view>
			</view> -->
			<view class="question-block">
				<uni-collapse accordion="true">
						<uni-collapse-item 
						:title="question.helpName"
							v-for="(question,index) in commonQuestionList" :key="index"
						>
							<view class="answer">
								<jyf-parser :html="question.content"  lazy-load ref="article" selectable
								 show-with-animation use-anchor @error="error" @imgtap="imgtap" @linkpress="linkpress" @ready="ready">加载中...</jyf-parser>
							</view>
						</uni-collapse-item>
				</uni-collapse>
			</view>
		</view>	
		
	</view>
</template>

<script>
	import commonTitle from'../../components/titile/title.vue'
	import uniCollapse from '../../components/uni-collapse/uni-collapse.vue'
	import uniCollapseItem from '../../components/uni-collapse-item/uni-collapse-item.vue'
	import jyfParser from '../../components/jyf-parser/jyf-parser.vue';
	export default{
		name:"signIn",
		data(){
			return{
				apptoken:"",
				commonQuestionList:"",//初始化常见问题
			}
		},
		components:{
			commonTitle,
			uniCollapse,
			uniCollapseItem,
			jyfParser
		},
		onLoad() {
			this.apptoken = uni.getStorageSync("apptoken");
			this.getCommonQuestion(31);
		},
		methods:{
			getQuestionDetail(id){
				console.log(id)
			},
			getCommonQuestion(id){
				const _this = this;
				//加载常见问题
				uni.request({
					url:this.$API.URL + this.$API.help,
					data:{"helpType":id},
					success(res){
						console.log(res);
						if(res.data.success){
							_this.commonQuestionList = res.data.data;
						}else{
							uni.showToast({
								title:res.data.msg,
								icon:"none"
							})
						}
					},
					fail(res){
						console.log(res)
					}
				})
			},
			//问题详情
			goQuestionDetail(id){
				this.navigateTo(id)
			},
			navigateTo(id){
				uni.navigateTo({
					url:'./questionDetail?id='+ id,
					animationType:'slide-in-right'
				})
			},
			ready(e) {
				console.log('ready', e);
				// console.log('api: getText', this.$refs.article.getText());
				console.log('imgList', this.$refs.article.imgList);
			},
			imgtap(e) {
				console.log('imgtap', e);
			},
			linkpress(e) {
				console.log('linkpress', e);
			},
			error(e) {
				console.error(e);
			}
		}
	}
</script>

<style>
	@import url("newDriver.css");
</style>
